const express = require('express')
const pool = require('../pool')
const router = express.Router()
// 登录接口
// http://localhost:3000/login
router.post('/',(req,res,next)=>{
    var obj=req.body
    pool.query('select * from qnls_user where user=?',[obj.user],(err,r)=>{
        console.log(r);
        if(err) {
            return next(err)
        }
        if(r.length === 0){
            return res.send({code:400,msg:'账号不存在'})
        }
        if(r[0].pwd==obj.pwd){ 
            res.send({code:200,msg:'登录成功',data:r[0]})
        }else{
            res.send({code:400,msg:'密码错误',data: r ,obj}) 
        }
    })
})
module.exports = router